package hc.um.action;

import hc.um.service.UserService;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class QueryScheduleListServlet
 */
@WebServlet("/QueryScheduleListServlet")
public class QueryScheduleListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	private UserService userService = new UserService();
	
    /**
     * @see HttpServlet#HttpServlet()
     */
    public QueryScheduleListServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		System.out.println("query schedule list");
		this.getScheduleList(request, response);			
	}

	public void getScheduleList(HttpServletRequest request,
			HttpServletResponse response) throws IOException {
		int hospitalid = 0;	
		String startdate = null;
		String enddate = null;
		String doctorid = null;
		String doctorname = null;	
		
		hospitalid = Integer.parseInt(request.getParameter("hospitalid"));
		startdate = request.getParameter("startDate");
		enddate = request.getParameter("endDate");
		doctorid = request.getParameter("doctorid");
		doctorname = request.getParameter("nameselected");
		
		response.getWriter().write(userService.getScheduleRecords(hospitalid, startdate, enddate, doctorid, doctorname));
	}	
}
